"use strict";
const DateUtil = require("../node_modules/unisoft-web-util/src/util/DateUtil.js");
const vue = require("vue");
const index = require("../node_modules/element-plus/es/components/date-picker/index.js");
const UtDatePick = vue.defineComponent({
  props: {
    item: {
      type: Object
    },
    model: {
      type: Object
    },
    disabled: Boolean
  },
  setup(props, { emit }) {
    let isArray;
    if (props.item.props.type.indexOf("range") > 0) {
      isArray = true;
    } else {
      isArray = false;
    }
    return () => {
      return /* @__PURE__ */ React.createElement(index.ElDatePicker, {
        ...props.item.props,
        disabled: props.disabled,
        modelValue: props.model[props.item.name],
        "onUpdate:modelValue": (value) => {
          if (Array.isArray(value)) {
            for (let i = 0; i < value.length; i++) {
              value[i] = DateUtil.formatDataTime(value[i], props.item.props.format || DateUtil.YmdFormt);
            }
          } else {
            value = DateUtil.formatDataTime(value, props.item.props.format || DateUtil.YmdFormt);
          }
          emit("ValUpdate", props.item.name, value);
          if (props.item.nameAs) {
            if (isArray) {
              for (let i = 0; i < props.item.nameAs.length; i++) {
                const key = props.item.nameAs[i];
                emit("ValUpdate", key, value);
              }
            } else {
              emit("ValUpdate", props.item.nameAs, value);
            }
          }
        },
        onChange: () => {
          emit("onchange", props.item, props.model[props.item.name]);
        },
        onClear: () => {
          emit("onchange", props.item, props.model[props.item.name]);
        }
      });
    };
  }
});
module.exports = UtDatePick;
